package com.mtbu.bean.base;
import java.util.*;
import java.text.SimpleDateFormat;
import org.json.JSONObject;
import my.json.core.JsonAble;
public abstract class ProjectBase implements JsonAble {
    private Map<String, Object> dirtyProperties = new HashMap<String, Object>();
    //
    private int id = 0;
    //
    private String split = "";
    //
    private String name = "";
    //
    private int channelJoinFID = 0;
    //频道加入操作对应的FID
    private Date updateTime = null;
    //
    private Date createTime = null;
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        this.id = id;
    }
    public String getSplit(){
        return this.split;
    }
    public void setSplit(String split){
        this.split = split;
        dirtyProperties.put("split", split);
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
        dirtyProperties.put("name", name);
    }
    public int getChannelJoinFID(){
        return this.channelJoinFID;
    }
    public void setChannelJoinFID(int channelJoinFID){
        this.channelJoinFID = channelJoinFID;
        dirtyProperties.put("channelJoinFID", channelJoinFID);
    }
    public Date getUpdateTime(){
        return this.updateTime;
    }
    public String getUpdateTime_ToDateString(){
        if(updateTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(this.updateTime);
    }
    public String getUpdateTime_ToTimeString(){
        if(updateTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(this.updateTime);
    }
    public String getUpdateTime_ToDateTimeString(){
        if(updateTime==null)   return "";
        SimpleDateFormat   formatter   =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(this.updateTime);
    }
    public void setUpdateTime(Date updateTime){
        this.updateTime = updateTime;
        dirtyProperties.put("updateTime", updateTime);
    }
    public Date getCreateTime(){
        return this.createTime;
    }
    public String getCreateTime_ToDateString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToTimeString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToDateTimeString(){
        if(createTime==null)   return "";
        SimpleDateFormat   formatter   =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public void setCreateTime(Date createTime){
        this.createTime = createTime;
        dirtyProperties.put("createTime", createTime);
    }
    public Map<String, Object> getDirtyProperties() {
        return this.dirtyProperties;
    }
    public JSONObject toJSON() throws Exception {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        json.put("id", this.getId());
        if(split!=null){
           json.put("split",this.getSplit());
        }
        if(name!=null){
           json.put("name",this.getName());
        }
        json.put("channelJoinFID", this.getChannelJoinFID());
        if(updateTime!=null){
            json.put("updateTime",formatter.format(this.getUpdateTime()));
        }
        if(createTime!=null){
            json.put("createTime",formatter.format(this.getCreateTime()));
        }
        return json;
    }
    public void fromJSON(JSONObject json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            if(json.get("id") != null){
                this.setId(Integer.parseInt(json.get("id")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("split") != null){
                this.setSplit(json.get("split")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("name") != null){
                this.setName(json.get("name")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("channelJoinFID") != null){
                this.setChannelJoinFID(Integer.parseInt(json.get("channelJoinFID")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("updateTime") != null){
                this.setUpdateTime(formatter.parse(json.get("updateTime")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("createTime") != null){
                this.setCreateTime(formatter.parse(json.get("createTime")+""));
            }
        }catch(Exception ex){
        }
    }
    public void fromMap(Map<String, String> json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            if(json.containsKey("id".toLowerCase())){
                this.setId(Integer.parseInt(json.get("id".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("split".toLowerCase())){
                this.setSplit(json.get("split".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("name".toLowerCase())){
                this.setName(json.get("name".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("channelJoinFID".toLowerCase())){
                this.setChannelJoinFID(Integer.parseInt(json.get("channelJoinFID".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("updateTime".toLowerCase())){
                this.setUpdateTime(formatter.parse(json.get("updateTime".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("createTime".toLowerCase())){
                this.setCreateTime(formatter.parse(json.get("createTime".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
    }
}
